import 'package:FiduMart/generated/json/base/json_convert_content.dart';
import 'package:FiduMart/core/network/model/box_list_entity.dart';

BoxListEntity $BoxListEntityFromJson(Map<String, dynamic> json) {
  final BoxListEntity boxListEntity = BoxListEntity();
  final List<BoxListList>? list = (json['List'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<BoxListList>(e) as BoxListList).toList();
  if (list != null) {
    boxListEntity.list = list;
  }
  return boxListEntity;
}

Map<String, dynamic> $BoxListEntityToJson(BoxListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['List'] = entity.list?.map((v) => v.toJson()).toList();
  return data;
}

extension BoxListEntityExt on BoxListEntity {
  BoxListEntity copyWith({
    List<BoxListList>? list,
  }) {
    return BoxListEntity()
      ..list = list ?? this.list;
  }
}

BoxListList $BoxListListFromJson(Map<String, dynamic> json) {
  final BoxListList boxListList = BoxListList();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    boxListList.id = id;
  }
  final String? nameZh = jsonConvert.convert<String>(json['nameZh']);
  if (nameZh != null) {
    boxListList.nameZh = nameZh;
  }
  final String? nameEn = jsonConvert.convert<String>(json['nameEn']);
  if (nameEn != null) {
    boxListList.nameEn = nameEn;
  }
  final String? nameTh = jsonConvert.convert<String>(json['nameTh']);
  if (nameTh != null) {
    boxListList.nameTh = nameTh;
  }
  final int? boxType = jsonConvert.convert<int>(json['boxType']);
  if (boxType != null) {
    boxListList.boxType = boxType;
  }
  final String? coverUrl = jsonConvert.convert<String>(json['coverUrl']);
  if (coverUrl != null) {
    boxListList.coverUrl = coverUrl;
  }
  final int? cycle = jsonConvert.convert<int>(json['cycle']);
  if (cycle != null) {
    boxListList.cycle = cycle;
  }
  final int? startTime = jsonConvert.convert<int>(json['startTime']);
  if (startTime != null) {
    boxListList.startTime = startTime;
  }
  final int? endTime = jsonConvert.convert<int>(json['endTime']);
  if (endTime != null) {
    boxListList.endTime = endTime;
  }
  final int? buyPrice = jsonConvert.convert<int>(json['buyPrice']);
  if (buyPrice != null) {
    boxListList.buyPrice = buyPrice;
  }
  final double? price = jsonConvert.convert<double>(json['price']);
  if (price != null) {
    boxListList.price = price;
  }
  final int? buyLimit = jsonConvert.convert<int>(json['buyLimit']);
  if (buyLimit != null) {
    boxListList.buyLimit = buyLimit;
  }
  final int? buyMax = jsonConvert.convert<int>(json['buyMax']);
  if (buyMax != null) {
    boxListList.buyMax = buyMax;
  }
  final int? buyNum = jsonConvert.convert<int>(json['buyNum']);
  if (buyNum != null) {
    boxListList.buyNum = buyNum;
  }
  final int? totalBuyNum = jsonConvert.convert<int>(json['totalBuyNum']);
  if (totalBuyNum != null) {
    boxListList.totalBuyNum = totalBuyNum;
  }
  final String? showReturnRate = jsonConvert.convert<String>(
      json['showReturnRate']);
  if (showReturnRate != null) {
    boxListList.showReturnRate = showReturnRate;
  }
  final String? showReturnStoneNum = jsonConvert.convert<String>(
      json['showReturnStoneNum']);
  if (showReturnStoneNum != null) {
    boxListList.showReturnStoneNum = showReturnStoneNum;
  }
  final int? state = jsonConvert.convert<int>(json['state']);
  if (state != null) {
    boxListList.state = state;
  }
  final int? sortAt = jsonConvert.convert<int>(json['sortAt']);
  if (sortAt != null) {
    boxListList.sortAt = sortAt;
  }
  final int? createdAt = jsonConvert.convert<int>(json['createdAt']);
  if (createdAt != null) {
    boxListList.createdAt = createdAt;
  }
  return boxListList;
}

Map<String, dynamic> $BoxListListToJson(BoxListList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['nameZh'] = entity.nameZh;
  data['nameEn'] = entity.nameEn;
  data['nameTh'] = entity.nameTh;
  data['boxType'] = entity.boxType;
  data['coverUrl'] = entity.coverUrl;
  data['cycle'] = entity.cycle;
  data['startTime'] = entity.startTime;
  data['endTime'] = entity.endTime;
  data['buyPrice'] = entity.buyPrice;
  data['price'] = entity.price;
  data['buyLimit'] = entity.buyLimit;
  data['buyMax'] = entity.buyMax;
  data['buyNum'] = entity.buyNum;
  data['totalBuyNum'] = entity.totalBuyNum;
  data['showReturnRate'] = entity.showReturnRate;
  data['showReturnStoneNum'] = entity.showReturnStoneNum;
  data['state'] = entity.state;
  data['sortAt'] = entity.sortAt;
  data['createdAt'] = entity.createdAt;
  return data;
}

extension BoxListListExt on BoxListList {
  BoxListList copyWith({
    String? id,
    String? nameZh,
    String? nameEn,
    String? nameTh,
    int? boxType,
    String? coverUrl,
    int? cycle,
    int? startTime,
    int? endTime,
    int? buyPrice,
    double? price,
    int? buyLimit,
    int? buyMax,
    int? buyNum,
    int? totalBuyNum,
    String? showReturnRate,
    String? showReturnStoneNum,
    int? state,
    int? sortAt,
    int? createdAt,
  }) {
    return BoxListList()
      ..id = id ?? this.id
      ..nameZh = nameZh ?? this.nameZh
      ..nameEn = nameEn ?? this.nameEn
      ..nameTh = nameTh ?? this.nameTh
      ..boxType = boxType ?? this.boxType
      ..coverUrl = coverUrl ?? this.coverUrl
      ..cycle = cycle ?? this.cycle
      ..startTime = startTime ?? this.startTime
      ..endTime = endTime ?? this.endTime
      ..buyPrice = buyPrice ?? this.buyPrice
      ..price = price ?? this.price
      ..buyLimit = buyLimit ?? this.buyLimit
      ..buyMax = buyMax ?? this.buyMax
      ..buyNum = buyNum ?? this.buyNum
      ..totalBuyNum = totalBuyNum ?? this.totalBuyNum
      ..showReturnRate = showReturnRate ?? this.showReturnRate
      ..showReturnStoneNum = showReturnStoneNum ?? this.showReturnStoneNum
      ..state = state ?? this.state
      ..sortAt = sortAt ?? this.sortAt
      ..createdAt = createdAt ?? this.createdAt;
  }
}